// ------------------------------------------------------------------------------
// 
// Copyright (c) 2007-2008 Swampware, Inc.
// 
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// 
// ------------------------------------------------------------------------------
using System;

namespace Water.Blocks
{
	/// <summary>
	/// Summary description for BlockReader.
	/// </summary>
	public class BlockReader : Water.TextReader
	{
		private Water.List _statements;
		private int _position = 0;
		private string _file;
		private int _line;
		private int _column;

		public BlockReader(Water.List statements)
		{
			this._statements = statements;
			this.Next();
		}

		public void Next()
		{
			if(this._statements.Count > this._position)
			{
				Water.Statement statement = (Water.Statement)this._statements[this._position];
				this._position++;

				this._file = statement.File;
				this._line = statement.Line;
				this._column = statement.Column;
			}
			else
			{
				this._position++;
			}
		}

		public override string Filename
		{
			get { return this._file; }
		}

		public override int LineNumber
		{
			get { return this._line; }
		}

		public override int ColumnNumber
		{
			get { return this._column; }
		}

		public override bool CanRead
		{
			get { return (this._statements.Count >= this._position); }
		}

		public override int Peek()
		{
			#region Peek

			throw new System.Exception("Not implemented.");

			#endregion
		}

		public override int Read()
		{
			#region Read

			throw new System.Exception("Not implemented.");

			#endregion
		}

		public override string ReadLine()
		{
			#region ReadLine

			throw new System.Exception("Not implemented.");

			#endregion
		}

		public override void Close()
		{
			#region Close

			throw new System.Exception("Not implemented.");

			#endregion
		}

	}
}
